class MouseRightMenuManager
  
  def initialize uicontext
    @uicontext = uicontext
		@popupMenu = Gtk::Menu.new
		@popupMenu.append(@uicontext.menuItemsManager.getCreateTaskMenuItem)
    @popupMenu.append(@uicontext.menuItemsManager.getCreateSubTaskMenuItem)
    @popupMenu.append(@uicontext.menuItemsManager.getUpdateTaskMenuItem)
    @popupMenu.append(@uicontext.menuItemsManager.getDeleteTaskMenuItem)
		@popupMenu.show_all
  end
  
#  def registerPopupMenu2ListPanel
#    @uicontext.listPanelManager.getListPanel.add_events(Gdk::Event::BUTTON_PRESS_MASK)
#    @uicontext.listPanelManager.getListPanel.signal_connect("button_press_event") do |widget, event|
#      if (event.button == 3)
#        @popupMenu.popup(nil, nil, event.button, event.time)
#      end	
#    end
#  end
  
  def registerPopupMenu2TreePanel
    @uicontext.treePanelManager.getTreePanel.add_events(Gdk::Event::BUTTON_PRESS_MASK)
    @uicontext.treePanelManager.getTreePanel.signal_connect("button_press_event") do |widget, event|
      if (event.button == 3)
        @uicontext.selected = @uicontext.treePanelManager.getSelected
				if @uicontext.selected == nil
					@uicontext.menuItemsManager.getCreateSubTaskMenuItem.sensitive = false
					@uicontext.menuItemsManager.getUpdateTaskMenuItem.sensitive = false
					@uicontext.menuItemsManager.getDeleteTaskMenuItem.sensitive = false
				else
					@uicontext.menuItemsManager.getCreateSubTaskMenuItem.sensitive = true
					@uicontext.menuItemsManager.getUpdateTaskMenuItem.sensitive = true
					@uicontext.menuItemsManager.getDeleteTaskMenuItem.sensitive = true
				end
        @popupMenu.popup(nil, nil, event.button, event.time)
      end 
    end
  end
  
end
